package com.danieldura.highrise.requests
{
	import com.danieldura.highrise.HighriseCredentials;
	import com.danieldura.highrise.data.Case;
	import com.danieldura.highrise.data.Company;
	import com.danieldura.highrise.data.Note;
	import com.danieldura.highrise.data.Person;
	
	import flash.net.URLRequestMethod;
	
	public class NotesRequest extends HighriseRequest
	{
		
		public function NotesRequest( credentials:HighriseCredentials )
		{
			super( credentials, new HighriseRequestDataMap( "note", "notes", Note ) );
		}
		
		public function show( id:int ):HighriseRequestToken
		{
			requestMethod = URLRequestMethod.GET;
			location = "/notes/" + id + format;
			return send();
		}
		
		public function listAll( offset:int ):HighriseRequestToken
		{
			requestMethod = URLRequestMethod.GET;
			location = "/notes" + format;
			return send();
		}
		
		public function getFromPerson( person:Person ):HighriseRequestToken
		{
			requestMethod = URLRequestMethod.GET;
			location = "/people/" + person.id + "notes" + format;
			return send();		
		}
		
		public function getFromCompany( company:Company ):HighriseRequestToken
		{
			requestMethod = URLRequestMethod.GET;
			location = "/companies/" + company.id + "notes" + format;
			return send();		
		}
		
		public function getFromCase( kase:Case ):HighriseRequestToken
		{
			requestMethod = URLRequestMethod.GET;
			location = "/kases/" + kase.id + "notes" + format;
			return send();		
		}
		
		public function create( note:Note ):HighriseRequestToken
		{
			requestMethod = URLRequestMethod.POST;
			location = "/notes.xml"
			requestData = note.toXMLString();
			return send();		
		}
		
		public function update( note:Note ):HighriseRequestToken
		{
			requestMethod = "PUT";
			location = "/notes/" + note.id + ".xml";
			requestData = note.toXMLString();
			return send();		
		}
		
		public function destroy( note:Note ):HighriseRequestToken
		{
			requestMethod = "DELETE";
			location = "/notes/" + note.id + ".xml";
			return send();		
		}
		
	}
}